<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script src="./js/jquery-1.11.0.js" type="text/javascript"></script>
    <script>
        $(function(){
            $("#btn").click(function(){
                $("#sp").text("点击了按钮")
            })

            $("#btn").dblclick(function(){
                $("#sp").text("双击击了按钮")
            })

            $("#in").blur(function(){
                $("#sp").text("input失去了焦点")
            })

            $("#in").focus(function(){
                $("#sp").text("input获得了焦点")
            })

            $("#in").change(function(){
                $("#sp").text("input发生了改变")
            })

            $("#ajax_btn").click(function(){
                var val = $("#ajax_id").val();
                $.ajax({
                    url:"/ajax/getId",
                    type:"POST",
                    data:"id="+val,
                    success:function(data){
                        console.log(data);
                        $("#ajax_sp").text(data.name+"   "+data.password);
                    },
                    dataType:"json"
                });
            })

            $("#model_btn").click(function(){
                var username = $("#username").val();
                var password = $("#password").val();
                $.ajax({
                    type:"POST",
                    url:"/ajax/getModel",
                    contentType:"application/json;charset=UTF-8",
                    data:JSON.stringify({"name":username,"password":password}),
                    success:function(data){
                        console.log(data)
                    },
                    dataType:"json"
                })

            })
        })


    </script>
</head>
<body>
<h2>Hello World!</h2>
</body>
<a href="test/testModelAndView">[返回值是ModelAndView]</a> <br>
<a href="test/testVoid">[返回值是testVoid]</a> <br>
<a href="test/hello">[返回值是Map]</a> <br>
<a href="test/index">[index]</a> <br>
<a href="test/testForward">[forward]</a> <br>
<a href="test/testRedirect">[redirect]</a> <br>

<button id="btn">按钮</button>
<div id="sp"></div>
<input type="text" id="in">


<input type="text" id="ajax_id" name="id"/>
<button id="ajax_btn">获取数据</button>
<span id="ajax_sp"></span>
<hr/>

username:<input type="text" id="username"  name="username"/>
password:<input type="text" id="password" name="password"/>
<button id="model_btn">提交对象</button>

<hr/>

<%--<% response.sendRedirect("/check.html");%>--%>
<a href="./check.html">表单验证</a>
</html>
